﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Web;
using System.Xml;
using System.Xml.Linq;
using Douban.Api;
using Douban.Api.Authorization;
using Douban.Api.Infrastructure;
using Douban.Api.Mail;
using Douban.Api.User;
using Douban.Api.Broadcast;
using System.Xml.Serialization;
using System.Windows.Input;

namespace Douban.TestConsole
{
    public enum KeyModifier
    { 
        Control = 0x01,
        Alt = 0x02,
        Win = 0x04,
        Shift = 0x08
    }

    public class Setting
    {
        [XmlArray]
        public KeyModifier[] Modifiers { get; set; }

        public Key VirtualKey { get; set; }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            //DoubanService doubanService = new DoubanService();
            //doubanService.Run();

            //FileSystemAccessTokenManager tokenManager = new FileSystemAccessTokenManager();

            //if (!doubanService.AuthorizationService.IsAccessTokenAvailable)
            //{
            //    Uri uri = doubanService.AuthorizationService.BeginAuthorize();
            //    Process.Start(uri.AbsoluteUri);
            //    Console.WriteLine("After authorize, press any key to continue");
            //    Console.ReadKey(true);

            //    doubanService.AuthorizationService.CompleteAuthorize();
            //}

            //string c1,c2;
            //UserDetail user = doubanService.UserService.GetCurrentUser();
            ////doubanService.MailService.TrySendMail(user.Id, "哈啊好", "哦哦哦", out c1, out c2);
            //MiniblogFeed miniblogFeed = doubanService.BroadcastService.GetMiniblogs(user.Id, 1, 50);
            //doubanService.BroadcastService.GetMiniblogComments(
            //    miniblogFeed.Miniblogs.FirstOrDefault(m => m.Category == "saying").Id);

            Setting setting = new Setting();
            setting.Modifiers = new KeyModifier[] { KeyModifier.Alt, KeyModifier.Control };
            setting.VirtualKey = Key.X;
            XmlSerializer serializer = new XmlSerializer(typeof(Setting));
            serializer.Serialize(Console.Out, setting);
        }
    }
}
